package com.tx.server.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 图片等文件资源映射路径
 * @author meff
 *
 */
@Configuration
public class ResourceConfigurer implements WebMvcConfigurer {
	
	@Value("${img.directory}")
	String imageDirectory;
	
	@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/resources/**").addResourceLocations("file:"+imageDirectory+"/");
        //http://localhost:8688/api/resources/8aed0d66-dda8-4142-8cc9-55fbc1057ffa.jpg
    }
}
